package com.example.lenovo.tianqi.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.lenovo.tianqi.R;

/**
 * Created by lenovo on 2018/1/10.
 */

public class OtherCityDialog extends Dialog implements View.OnClickListener{
    public OtherCityDialog(@NonNull Context context,MyDialogListenner listener) {
//        更改提示框的样式
        super(context,R.style.MyDialog);
        this.listener=listener;
    }
    private Button surebutton;
    private Button cancelbutton;
    private EditText editText;
    private View div_view;
    private MyDialogListenner listener;
    public interface  MyDialogListenner{
        void Clicksure(String cityName);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_other_city);
        initView();
    }

    private void initView() {
        surebutton=findViewById(R.id.dialog_sure);
        cancelbutton=findViewById(R.id.dialog_cancle);
        editText=findViewById(R.id.dialog_et_city);
        div_view=findViewById(R.id.div_line_city);
        surebutton.setOnClickListener(this);
        cancelbutton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.dialog_sure:
                listener.Clicksure(editText.getText().toString());
                this.cancel();
                break;
            case R.id.dialog_cancle:
                this.cancel();
                break;
        }

    }
}
